#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

void inherit (void)
{
	printf ("I will die...\n");
	return ;
}

void inherit1 (void)
{
	printf ("U will die...\n");
	return ;
}

int main (void)
{
	//注册遗言函数
	atexit (inherit);
	atexit (inherit1);
	
	//创建子进程
	pid_t pid = fork();
	if (-1 == pid) {
		perror ("fork()");
		return -1;
	}
	if (0 == pid) {
		//子进程
		getchar ();
	} else {
		printf ("I am parent!\n");
	}

	return 0;
}
